package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func ServerError(c *gin.Context) {
	Response(c, http.StatusInternalServerError, 500, "服务异常", nil)
}

func ModuleClose(c *gin.Context) {
	Response(c, http.StatusOK, 500, "功能尚未开通", nil)
}

func TokenError(c *gin.Context) {
	Response(c, http.StatusOK, 500, "无效token", nil)
}

func PasswordError(c *gin.Context) {
	Response(c, http.StatusOK, 500, "密码错误", nil)
}

func ParamError(c *gin.Context) {
	Response(c, http.StatusOK, 500, "请求参数不合法", nil)
}

func DataExist(c *gin.Context, tip string) {
	Response(c, http.StatusOK, 500, tip, nil)
}

func DataNotExist(c *gin.Context, tip string) {
	Response(c, http.StatusOK, 500, tip, nil)
}

func Success(c *gin.Context, data any) {
	Response(c, http.StatusOK, 200, "成功", data)
}

func Fail(c *gin.Context, msg string, data gin.H) {
	Response(c, http.StatusOK, 400, msg, data)
}

func Response(c *gin.Context, httpStatus int, code int, msg string, data any) {
	c.JSON(httpStatus, gin.H{"code": code, "msg": msg, "data": data})
}
